The Format of dbCGI Files
dbCGI files are just like standard HTML files, except that thefollowing are recognised:- <sql subcommand>....</sql>.
- Formatting escapes starting with '%'.
The SQL subcommands are:- init - Initialise the DBMS
- uninit - uninitialise the DBMS
- connect - connect to a database
- disconnect - disconnect from a database
- query - issue an SQL query to a connection
- execute - issue an SQL command to a connection
- format - format the results of an SQL query
- headings - format the headings of an SQL query
- error - specify a format for errors from the database
- valarg - validate arguments received through the HTTP query string
- valform - validate a value received from a form
The formatting escapes are:- %% - substitutes to the '%' character
- %$ - substitutes to the process ID
- %# - substitutes to a sequence number, unique per output record producedsince starting dbCGI
- %nd - where n is a number starting at 1 -substitutes to value of the named column of the output record (used in thesql format command)
- %nh - where n is a numberstarting at 1 - substitutes to the heading of the named column of theoutput record (used in the sql format or sql headings commands)
- %na - where n is a numberstarting at 1 - substitutes to an argument from the HTTP query string
- %e - substitutes to the current error message text (used in the sqlerror command)
- %c - substitutes to the SQL command that caused the current error (usedin the sql error command)
- %n - (A literal n this time) substitutes to the current error number(used in the sql error command)
- %v - substitutes to the value which failed validation (used in thesql valarg and sql valform commands)
- %{text%} - generates an escaped representation of the enclosed text.All non alphanumeric characters are escaped.
- %n(text%) - where n is anumber starting at 1 - only include theenclosed text if the specified result column is not null.
- %[!n1,n2,n3,...:text%] - wheren1, n2,n3 and so on are column numbers,include the text only if the values in the listed columns have notchanged since the previous record.
- %n[@filename%] - where n isthe column number of a BLOB or charactercolumn, store the value of the named column in the named file. This is usuallyused in conjunction with %$ and %# to create uniquefile names.
- %[|command%] - execute the named command
- %['text%] - double up any single quote characters in the text
- %["text%] - double up any double quote characters in the text
- %[\text%] - double up any backslash characters in the text
- %[-text%] - prevent the enclosed text from being reformatted forpresentation as HTML (stops remappings such as "<" to< and new lines to <BR>)
- %[=var%] - substitutes the value of the named form variable
- %[=var:text%] - substitutes the value of the named form variable, or ifthe variable was not received, substitute the text.
- %[?var:text%] - substitutes the text if the named form variable wasreceived.
- %[~var:text%] - substitutes the text if the named form variable wasnot received.
- %[*var:text%] - sets the value of the named form variable.
The %[...%], %{...%} and %(...%) sequences may all be nested.Below is the layout of a sample dbCGI file for Informix.
CorVu dbCGI for Informix Test INFORMIXDIR=/usr/informix SQLEXEC=/usr/informix/lib/sqlturbo TBCONFIG=tbconfig DATABASE=stores %[!8:%8d
%] %[!7,8:%7d
%] %[!7,8,9:%9d
%] %4d
%3d %2d
%5d
%6(%6d
%) %10d
select * from customer order by state, city, zipcode The query above accesses the customers table from the Informix sales demonstrationdatabase and prints a list with breaks by state, city and zipcode (columns 8, 7 and9). Column 6, which contains an optional second address line, is only displayed ifit is populated.